<?php
my_component_load('testing' , false);
my_component_load('paging' , false);  
my_component_load('seleksi_internal' );
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$sid = isset( $_GET['sid'] ) ? $_GET['sid']:  0;
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;

$modulname = "Personalia _BN_ Penempatan _BN_ Rekruitment _BN_ Internal"; 
if($_SERVER['REQUEST_METHOD'] == "POST" ):
	switch($task){ 
		case "edit_detail_update_page":
		case "edit_detail_page":
			if( isset($_POST['gaji'] )){
				$validatepost = seleksi_internal_detail_validate($sid , $id);
				if($validatepost){
					$errors = message_multi_error($validatepost);
					$content = $errors;
					$content .= form_seleksi_internal_detail($sid,$id);
					generate_my_web($content, $pagename ,"plain.php");
					exit;
				}else{	
					submit_seleksi_internal_detail($sid,$id);
					generate_my_web('Updated', $pagename ,"plain.php");
				exit;
				}
			}else{
				$validatepost = seleksi_internal_detail_validate($sid , $id);
				if($validatepost){
					$errors = message_multi_error($validatepost);
					$content = $errors;
				}else{	
					$content = '';
				}	
				$content .= form_seleksi_internal_detail($sid,$id);
				generate_my_web($content, $pagename ,"plain.php");
				exit;
			}			
			break; 
		case "edit_page":
			submit_seleksi_internal($sid);
			generate_my_web('Updated', $pagename ,"plain.php");
			exit;
		break;
	}

else: 	
	if($task == "detail"){ 
		$pagename = $modulname." _BN_ Detail";
		load_facebox_script();
		$content = detail_seleksi_internal($sid);
	}elseif($task == "delete_detail"){ 
		seleksi_delete_detail($id);
		my_direct($_SERVER['HTTP_REFERER']);
	}elseif($task == "delete"){ 
		seleksi_delete($id);
		my_direct($_SERVER['HTTP_REFERER']);
	}elseif($task == "edit"){ 
		$pagename = ($sid > 0 ) ? "Perubahan Data" : "Tambah Data";
		facebox_page('index.php?com=seleksi_internal&task=edit_page&sid='.$sid , $pagename , 220	);
	}elseif($task == "edit_page"){
		$pagename = ($sid > 0 ) ? "Perubahan Data" : "Tambah Data";
		$content = form_seleksi_internal($sid);
		generate_my_web($content, $pagename ,"plain.php");
		exit;
	}elseif($task == "edit_detail_update"){ 
		$pagename = ($sid > 0 ) ? "Perubahan Data" : "Tambah Data";
		facebox_page('index.php?com=seleksi_internal&task=edit_detail_update_page&id='.$id.'&sid='.$sid , $pagename , 440	);
	}elseif($task == "edit_detail"){ 
		$pagename = ($sid > 0 ) ? "Perubahan Data" : "Tambah Data";
		facebox_page('index.php?com=seleksi_internal&task=edit_detail_page&id='.$id.'&sid='.$sid , $pagename , 440	);
	}elseif($task == "edit_detail_update_page"){
		$pagename = ($sid > 0 ) ? "Perubahan Data" : "Tambah Data";
		$content = form_seleksi_internal_detail_update($sid,$id);
		generate_my_web($content, $pagename ,"plain.php");
		exit;
	}elseif($task == "edit_detail_page"){
		$pagename = ($sid > 0 ) ? "Perubahan Data" : "Tambah Data";
		$content = form_seleksi_internal_detail($sid,$id);
		generate_my_web($content, $pagename ,"plain.php");
		exit;
	}else{ 
		$pagename = $modulname;
		load_facebox_script();
		$content =  list_seleksi_internal(); 
		
	}
endif;  
generate_my_web($content, $pagename );
?>